package com.holystone.splunk.app.utils;

/**
 * Copyright (c) 2017, HOLYSTONE Technologies, Inc.
 * All right reserved.
 * <p>
 * Created by huyan on 2018/1/8.
 * TIME: 10:47
 * DESC:
 */
public class AlertUtils {

    /**
     * 将告警名称以 "-" 截取保存 比如 "websense-异常互联网访问请求"
     * @param firedAlertName
     *      从Splunk端获取的告警名称
     * @return
     */
    public static String getAlertName(String firedAlertName) {
        if (firedAlertName == null || "".equals(firedAlertName))
            return "";
        String[] splits = firedAlertName.split("-");
        if (splits.length == 1) {
            return firedAlertName;
        } else if (splits.length > 1) {
            StringBuilder sb = new StringBuilder();
            for (int i = 1; i < splits.length; i++) {
                sb.append(splits[i]);
            }
            return sb.toString();
        }
        return "";
    }
}
